<?php


namespace App\Service\Pay;


class AliPay extends AbstractPay
{
    public function init(){
        //echo 'alipay->pay';

    }
    public function exec()
    {
        // TODO: Implement exec() method.

        $price = 1;
        $params = new \Yurun\PaySDK\AlipayApp\Params\PublicParams;
        $pay_config =  systemConfig(['alipay_appid','alipay_merchant_private_key','alipay_public_key']);
        dump($pay_config);
        $params->appID = $pay_config['alipay_appid'];
        $params->appPrivateKey=$pay_config['alipay_merchant_private_key'];
        $params->appPublicKey=$pay_config['alipay_public_key'];

        $pay = new \Yurun\PaySDK\AlipayApp\SDK($params);
//        $request = new \Yurun\PaySDK\AlipayApp\Wap\Params\Pay\Request;
        $request = new \Yurun\PaySDK\AlipayApp\App\Params\Pay\Request;

        $request->businessParams->subject = $this->getTitle(); // 商品描述
        $request->businessParams->out_trade_no = $this->getOrderSn(); // 订单号
        $request->businessParams->total_amount  = $this->getPrice(); // 订单总金额，单位为：分
        $request->notify_url = systemConfig('site_url').$this->getNotifyUrl(); // 异步通知地址
        dump($request->notify_url);
        $pay->prepareExecute($request, $url,$data);
        return http_build_query($data);
    }

}